<?php

namespace app\forms\menu;

use yii\db\Exception;
use app\forms\Model;
use app\models\Menu;
use yii\web\HttpException;
use app\helpers\MappingHelper;

/**
 * 菜单 首页
 */
class IndexForm extends Model
{
    /**
     * @param $param
     * @return mixed
     * @throws HttpException
     */
    public static function index($param)
    {
        try {

            $resp['typeList'] = Menu::getTypeMapping();
            $resp['statusList'] = MappingHelper::statusList();
            $resp['targetList'] = Menu::getTargetMapping();
            $resp['menu'] = (new Menu)->getTree();
            return $resp;

        } catch (Exception $e) {
            (new self())->serverError();
        }
    }
}